import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xindong/common/xindong_sezhi.dart';
import 'package:xindong/manager/xindong_page_singleton.dart';
import 'package:xindong/manager/xindong_user_controller.dart';
import 'package:xindong/routes/user/follow/xindong_fans_yemian.dart';
import 'package:xindong/routes/user/follow/xindong_follow_yemian.dart';
import 'package:xindong/routes/user/friend/xindong_friend_yemian.dart';

class XinDongWoDeCounterView extends StatelessWidget {
  const XinDongWoDeCounterView({super.key});

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 60,
      width: double.infinity,
      child: GetBuilder<XinDongUserController>(builder: (controller) {
        return Row(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            _buildItem("好友", "${controller.userInfo?.friend ?? 0}", () {
              XinDongPageSingleton.instance.pushYeMian(const XinDongFriendYeMian());
            }),
            Container(width: 1, height: 20, color: DZColors.hexColor(0xdddddd)),
            _buildItem("关注", "${controller.userInfo?.following ?? 0}", () {
              XinDongPageSingleton.instance.pushYeMian(const XinDongFollowYeMian());
            }),
            Container(width: 1, height: 20, color: DZColors.hexColor(0xdddddd)),
            _buildItem("粉丝", "${controller.userInfo?.attention ?? 0}", () {
              XinDongPageSingleton.instance.pushYeMian(const XinDongFansYeMian());
            }),
          ],
        );
      }),
    );
  }

  Widget _buildItem(String title, String value, Function() onTap) {
    return Expanded(
      flex: 1,
      child: GestureDetector(
        onTap: onTap,
        behavior: HitTestBehavior.opaque,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Text(value, style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w500, color: DZColors.titleColor)),
            const SizedBox(height: 5),
            Text(title, style: const TextStyle(fontSize: 14, color: DZColors.placeholderColor)),
          ],
        ),
      ),
    );
  }
}
